package com.fredy.mvp;

import android.app.Activity;
import android.content.Context;

import androidx.fragment.app.Fragment;

public abstract class BaseMvpFragment<M extends Model, V extends BaseView, P extends BasePresenter>
        extends Fragment implements BaseMvp<M, V, P> {

    public P presenter;
    public Activity mActivity; 

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        mActivity = (Activity) context;
        presenter = createPresenter();
        if (presenter != null) {
            presenter.registerModule(createModel());
            presenter.registerView(createView());
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        if (presenter != null) {
            presenter.destroy();
        }
    }
}
